<?php

namespace App\Http\Requests\Api;

class PartTimeResumeRequest extends ApiRequest
{
    public function rules()
    {
        $time_start = '';
        $time_end = '';
        if (!empty($this->input('time_start'))) {
            $time_end = 'bail|required|date|after:time_start';
        }

        if (!empty($this->input('time_end'))) {
            $time_start = 'bail|required|date';
        }

        return [
            'id' => $this->is('*/update') ? 'required|integer' : '',
            'free_time' => 'required',
            'name' => 'required',
            'sex' => 'bail|required|integer',
            'birthday' => 'bail|required|date|before:now',
            'address' => 'bail|required|integer',
            'student' => 'bail|required|integer',
            'height' => 'integer',
            'time_start' => $time_start,
            'time_end' => $time_end,
            'education' => 'integer',
            'mobile' => 'bail||required|mobile_verification',
            'qq' => 'check_qq',
            'content' => 'bail|required|min:3',
            'intention' => 'required',
            'place' => 'bail|required|integer',
        ];
    }

    public function attributes()
    {
        return [
            'name' => '姓名',
            'sex' => '性别',
            'birthday' => '生日',
            'address' => '居住地',
            'student' => '当前状态',
            'height' => '身高',
            'time_start' => '学校开始时间',
            'time_end' => '学校结束时间',
            'education' => '学历',
            'mobile' => '联系电话',
            'content' => '自我介绍',
            'intention' => '求职意向',
            'place' => '期望地点',
        ];
    }

    public function messages()
    {
        return array_merge(parent::messages(), [
            'time_end.after' => '结束日期需要大于开始日期',
            'mobile.mobile_verification' => '请输入正确的手机号码',
            'qq.check_qq' => 'qq格式不正确',
        ]);
    }

}
